package work.mediway.mdm.biz.entity.hierarchy;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 组织人员职位表
 *
 * @author ruoyi
 * @since 2022-08-25
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("HOS_EmpPostion")
@ApiModel(value = "HosEmpPostion对象", description = "组织人员职位表")
public class HosEmpPostion implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "组织部门代码")
    @TableId(value = "EMPPOS_ORGCode", type = IdType.ASSIGN_ID)
    private String empPosOrgCode;

    @ApiModelProperty(value = "人员唯一标识码")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_PAPersonID")
    private String empPosPaPersonId;

    @ApiModelProperty(value = "职位代码")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_POSCode")
    private String empPosPosCode;

    @ApiModelProperty(value = "任职日期")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_AppointDate"
    )
    private String empPosAppointDate;

    @ApiModelProperty(value = "任职方式")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_NULL,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_AppointMode")
    private String empPosAppointMode;

    @ApiModelProperty(value = "免职日期")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_RemoveDate")
    private String empPosRemoveDate;

    @ApiModelProperty(value = "免职方式")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_NULL,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_RemoveMode")
    private String empPosRemoveMode;

    @ApiModelProperty(value = "任职状态")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.IGNORED,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_Status")
    private String empPosStatus;

    @ApiModelProperty(value = "是否有效")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_NULL,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_Activity")
    private String empPosActivity;

    @ApiModelProperty(value = "开始日期")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_StartDate")
    private String empPosStartDate;

    @ApiModelProperty(value = "结束日期")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_EndDate")
    private String empPosEndDate;

    @ApiModelProperty(value = "系统创建日期")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_CreateDate")
    private String empPosCreateDate;

    @ApiModelProperty(value = "系统创建时间")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_CreateTime")
    private String empPosCreateTime;

    @ApiModelProperty(value = "系统创建人")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_CreateUser")
    private String empPosCreateUser;

    @ApiModelProperty(value = "系统排序号")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.IGNORED,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_SeqNo")
    private Integer empPosSeqNo;

    @ApiModelProperty(value = "系统最后更新日期")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_LastUpdateDate")
    private String empPosLastUpdateDate;

    @ApiModelProperty(value = "系统最后更新时间")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_LastUpdateTime")
    private String empPosLastUpdateTime;

    @ApiModelProperty(value = "系统最新更新人")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.NOT_EMPTY,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_LastUpdateUser")
    private String empPosLastUpdateUser;

    @ApiModelProperty(value = "拼音码")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.IGNORED,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_PYCode")
    private String empPosPyCode;

    @ApiModelProperty(value = "五笔码")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.IGNORED,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_WBCode")
    private String empPosWbCode;

    @ApiModelProperty(value = "备注")
    @TableField(
            insertStrategy = FieldStrategy.NOT_EMPTY,
            updateStrategy = FieldStrategy.IGNORED,
            whereStrategy = FieldStrategy.NOT_EMPTY, 
            value = "EMPPOS_Mark")
    private String empPosMark;

    public static void setCreateHosEmpPostion(HosEmpPostion hosEmpPostion, String user) {
        hosEmpPostion.setEmpPosCreateUser(user);
        hosEmpPostion.setEmpPosCreateDate(DateUtil.now());
        hosEmpPostion.setEmpPosCreateTime(DateUtil.now());
        setUpdateHosEmpPostion(hosEmpPostion, user);
    }

    public static void setUpdateHosEmpPostion(HosEmpPostion hosEmpPostion, String user) {
        hosEmpPostion.setEmpPosLastUpdateDate(DateUtil.now());
        hosEmpPostion.setEmpPosLastUpdateTime(DateUtil.now());
        hosEmpPostion.setEmpPosLastUpdateUser(user);
        hosEmpPostion.setEmpPosStartDate(StringUtils.isNotEmpty(hosEmpPostion.getEmpPosStartDate()) ? hosEmpPostion.getEmpPosStartDate() : DateUtil.now());
        hosEmpPostion.setEmpPosEndDate(StringUtils.isNotEmpty(hosEmpPostion.getEmpPosEndDate()) ? hosEmpPostion.getEmpPosEndDate() : null);
    }
}
